#include "video_widget.h"

#include "include.h"
#include <QDateTime>



extern unsigned char frame_buffer[IMAGE_WIDTH*IMAGE_HEIGHT*3];

Video_Widget::Video_Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Video_Widget)
{
    ui->setupUi(this);
    this->setAttribute(Qt::WA_PaintOutsidePaintEvent);
    vsrun.start();
//    refresh_timer=new QTimer();
//    connect(refresh_timer,SIGNAL(timeout()),this,SLOT(refresh_timeout()));
//    refresh_timer->start(1000);
    connect(&vsrun,SIGNAL(frame_changed()),this,SLOT(update()));
}

Video_Widget::~Video_Widget()
{
    delete ui;
    vsrun.quit();
}
void Video_Widget::paintEvent(QPaintEvent *event )
{
   //QImage frame(frame_buffer,IMAGE_WIDTH,IMAGE_HEIGHT,QImage::Format_RGB888);
    QPainter widget_painter(this);
    widget_painter.drawImage(rect(), vsrun.process_frame);

}

void Video_Widget::refresh_timeout()
{

}
